package com.david.autostarter.logger.starter;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class MyLogFactoryBean<T> extends AbstractMyLogFactoryBean {
    @SuppressWarnings("unchecked")
    @Override
    public void afterPropertiesSet() throws Exception {
        T target = (T) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { getMapperInterface() }, new InvocationHandler() {

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                return "JDK:"+getLogSupport().invoke(method, args);
            }
        });
        setProxyTarget(target);
    }


}
